package com.smart.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.Type;

import com.smart.consts.InfoType;

/**
 * 通用信息
 * @author Sunxin
 *
 */

@Entity 
@Table(name = "Info") 
public class Info extends BaseEntity<Info>{
	private static final long serialVersionUID = 1L;
	/**
	 * @see com.smart.consts.InfoType
	 * 类型标记
	 */
	@Enumerated(EnumType.STRING)
	private InfoType type = InfoType.GENERAL;
	/**
	 * 标题
	 */
	@Column(length=2048)
	private String title;
	/**
	 * SEO keywords
	 */
	private String keywords;
	/**
	 * SEO description
	 */
	private String description;
	/**
	 * 来源
	 */
	private String source = "";
	/**
	 * 作者
	 */
	private String author = "";
	/**
	 * banner大图
	 */
	private String bannerImage;
	/**
	 * 图片名称
	 */
	private String titleImage;
	/**
	 * 用户自定义该资讯创建时间
	 */
	@Transient
	protected String crtTimeStr2;
	/**
	 * 概要
	 */
	@Column(length=2048)
	private String abstraction;
	/**
	 * 内容
	 */
	@Type(type="text") 
	@Column(nullable=true)
	private String content;
	/**
	 * 视频地址
	 */
	private String videoUrl;
	/**
	 * 查看次数
	 */
	private Long viewCount = 0L;
	
	public String getVideoUrl() {
		return videoUrl;
	}
	public void setVideoUrl(String videoUrl) {
		this.videoUrl = videoUrl;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getAbstraction() {
		return abstraction;
	}
	public void setAbstraction(String abstraction) {
		this.abstraction = abstraction;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getSource() {
		return source;
	}
	public void setSource(String source) {
		this.source = source;
	}
	public String getAuthor() {
		return author;
	}
	public void setAuthor(String author) {
		this.author = author;
	}
	public String getBannerImage() {
		return bannerImage;
	}
	public void setBannerImage(String bannerImage) {
		this.bannerImage = bannerImage;
	}
	public String getTitleImage() {
		return titleImage;
	}
	public void setTitleImage(String titleImage) {
		this.titleImage = titleImage;
	}
	public String getCrtTimeStr2() {
		return crtTimeStr2;
	}
	public void setCrtTimeStr2(String crtTimeStr2) {
		this.crtTimeStr2 = crtTimeStr2;
	}
	public InfoType getType() {
		return type;
	}
	public void setType(InfoType type) {
		this.type = type;
	}
	public Long getViewCount() {
		return viewCount;
	}
	public void setViewCount(Long viewCount) {
		this.viewCount = viewCount;
	}
	public String getKeywords() {
		return keywords;
	}
	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getContentUnEscaped(){
		if(content==null) {
			return "";
		}
		return content.replaceAll("&lt;", "<").replaceAll("&gt;", ">");
	}
	
}
